home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / mosmllib / Array2.sig < prev    next >
Encoding:
Text File  |  1996-07-03  |  2.3 KB  |  58 lines  |  [TEXT/R*ch]

  1. (* Array2 -- as of 1995-04-22 *)
  2.  
  3. eqtype 'a array2
  4.  
  5. val maxLen      : int
  6.  
  7. val array       : int * int * '_a -> '_a array2
  8. val tabulate    : int * int * (int * int -> '_a) -> '_a array2
  9.  
  10. val dim         : 'a array2 -> int * int
  11. val sub         : 'a array2 * int * int -> 'a
  12. val update      : 'a array2 * int * int * 'a -> unit
  13. val extract1    : 'a array2 * int * int * int option -> 'a Vector.vector
  14. val extract2    : 'a array2 * int * int * int option -> 'a Vector.vector
  15.  
  16. (* Type [ty array2] is the type of two-dimensional, mutable,
  17.    zero-based constant-time-access arrays with elements of type ty.
  18.    Type ty array admits equality even if ty does not.  Arrays a1 and
  19.    a2 are equal if both were created by the same call to a primitive,
  20.    or if both are empty.
  21.  
  22.    [maxLen] is the maximal number of elements in one dimension of an array.
  23.  
  24.    [array(m, n, x)] returns a new m * n matrix whose elements are all x.  
  25.    Raises Size if n<0 or m<0 or n>maxLen or m>maxLen.
  26.  
  27.    [tabulate(m, n, f)] returns a new m-by-n array whose elements
  28.    are f(0,0), f(0,1), ..., f(0, n-1), 
  29.        f(1,0), f(1,1), ..., f(1, n-1),
  30.                     ...
  31.        f(m-1,0),    ...,    f(m-1, n-1)
  32.    created in that order.  Raises Size if n<0 or m<0 or n>maxLen or m>maxLen.
  33.  
  34.    [dim a] returns the dimensions (m, n) of a.
  35.  
  36.    [sub(a, i, j)] returns the i'th row's j'th element, counting from 0.
  37.    Raises Subscript if i<0 or j<0 or i>=m or j>=n where (m,n) = dim a.
  38.  
  39.    [update(a, i, j, x)] destructively replaces the (i,j)'th element of a 
  40.    by x. Raises Subscript if i<0 or j<0 or i>=m or j>=n where (m,n) = dim a. 
  41.  
  42.    [extract1(a, i, j, NONE)] returns a subrow of a: the vector
  43.    containing the elements a[i][j..n-1] of a, where (m, n) = dim(a).
  44.    Raises Subscript if i<0 or j<0 or i>=m or j>n.
  45.  
  46.    [extract1(a, i, j, SOME len)] returns a subrow of a: the vector
  47.    containing the elements a[i][j..j+len-1] of a.  Raises Subscript if
  48.    i<0 or j<0 or i>=m or j+len>n where (m,n) = dim a.
  49.  
  50.    [extract2(a, i, j, NONE)] returns a subcolumn of a: the vector
  51.    containing the elements a[i..m-1][j] of a where (m,n) = dim a.
  52.    Raises Subscript if i<0 or j<0 or i>m or j>=n.
  53.  
  54.    [extract2(a, i, j, SOME len)] returns a subcolumn of a: the vector
  55.    containing the elements a[i..i+len-1][j] of a.  Raises Subscript if
  56.    i<0 or j<0 or i+len>m or j>=n where (m,n) = dim a.  
  57. *)
  58.